package cloudspace.vm.io.console;

import org.zkoss.zk.ui.Executions;


/**
 * TThis class represents an info stream line. This is the most basic element of
 * an Info Stream. It stores context information such as the content's of the
 * line, the timestamp for the line, the stream id the line is associated with,
 * and the line number of the info stream line.
 */
public class InfoStreamLine
{

    /** The line contents. */
    String lineContents;

    /** The timestamp. */
    long timestamp;

    /** The id. */
    String id;

    String deskContext;

    /** The line number. */
    long lineNumber;

    String textTimeStamp;


    /**
     * Instantiates a new info stream line.
     * 
     * @param streamID
     *            the stream id
     * @param userLine
     *            the user printed line
     * @param userStamp
     *            the user timestamp
     * @param userLN
     *            the user line number
     */
    public InfoStreamLine(
        String streamID,
        String timeStamp,
        String userLine,
        long userStamp,
        long userLN )
    {
        textTimeStamp = timeStamp;
        lineContents = userLine.intern();
        timestamp = userStamp;
        id = streamID;
        lineNumber = userLN;
        deskContext = "";
        if ( Executions.getCurrent() != null
            && Executions.getCurrent().getDesktop() != null )
        {
            deskContext = Executions.getCurrent().getDesktop().getId();
        }
    }


    /**
     * Gets the timestamp.
     * 
     * @return the timestamp
     */
    public long getTimestamp()
    {
        return timestamp;
    }


    /**
     * Gets the line.
     * 
     * @return the line
     */
    public String getLine()
    {
        return lineContents;
    }


    public String getLineWithTimestamp()
    {
        return textTimeStamp + " " + lineContents;
    }


    /**
     * Gets the string id.
     * 
     * @return the string id
     */
    public String getStreamID()
    {
        return id;
    }


    /**
     * Gets the line number.
     * 
     * @return the line number
     */
    public long getLineNumber()
    {
        return lineNumber;
    }


    /**
     * Sets the line.
     * 
     * @param line
     *            the new line
     */
    public void setLine( String line )
    {
        lineContents = line;

    }


    /**
     * Gets the id of the desktop this line is associated with.
     * 
     * @return the desktop id associated with this line.
     */
    public String getDesktopID()
    {
        return deskContext;
    }
}
